package com.yifeng.repo.base.constant;

/**
 * Created by daibing on 2023/9/8.
 */
public class BaseConstant {

    /**
     * 空字符串
     */
    public static final String EMPTY = "";

    /**
     * redis分隔符
     */
    public static final String REDIS_SEPARATOR = ":";

    /**
     * 默认分隔符：文本拼接
     */
    public static final String SEPARATOR = ",";

    /**
     * 无效编码
     */
    public static final String INVALID_CODE = "-1";

    /**
     * 下划线
     */
    public static final String UNDER_SCORE = "_";

    /**
     * 点
     */
    public static final String POINT = ".";

    /**
     * 数据库操作条数建议（包括in查询、返回结果集）
     */
    public static final Integer BATCH_SIZE_LIMIT = 1000;
    public static final Integer CORE_BATCH_SIZE_LIMIT = 500;
    public static final Integer BASE_BATCH_SIZE_LIMIT = 300;
    public static final Integer DETAIL_BATCH_SIZE_LIMIT = 100;
    public static final Integer UPDATE_BATCH_SIZE_LIMIT = 50;
    public static final Integer PAGE_SIZE_LIMIT = 20;

    /**
     * HTTP method
     */
    public static final String HTTP_GET_METHOD = "GET";
    public static final String HTTP_POST_METHOD = "POST";

    /**
     * header常量
     */
    public static final String TRACE_ID = "X-Trace-Id";
    public static final String FRONTEND_ID = "X-Frontend-Id";

    /**
     * 时间常量
     */
    public static final Long ONE_SECOND = 1L;
    public static final Long ONE_SECOND_MS = 1000 * ONE_SECOND;
    public static final Long ONE_MINUTE_MS = 60 * ONE_SECOND_MS;
    public static final Long ONE_HOUR_MS = 60 * ONE_MINUTE_MS;
    public static final Long ONE_DAY_MS = 24 * ONE_HOUR_MS;
    public static final Long ONE_WEEK_MS = 7 * ONE_DAY_MS;
    public static final Long THREE_SECOND_MS = 3 * ONE_SECOND_MS;
    public static final Long THREE_MINUTE_MS = 3 * 60 * ONE_SECOND_MS;

    /**
     * 按省拆库：省库二次路由基于Service层代码上的注解 @DS(BaseConstant.DS_PROVINCE_KEY)触发，基于门店编号做路由
     * 备注：每个省库都只有本省的数据，并且甚至公共数据剥离到一个共享库
     */
    public static final String DS_PROVINCE_KEY = "province";
    public static final String STORE_CODE_KEY = "storeCode";

    /**
     * 按省拆库方案增强，支持主库-热库-归档库的动态路由
     * 多库混合查询：Service层代码上的注解 @DS(BaseConstant.DS_MAIN_HOT_ARCHIVE_KEY)触发，基于请求头参数 DS_TYPE_HEADER 做路由，其他就按照实际切换数据源
     * 提示：请求头参数 DS_TYPE_HEADER的值仅支持 DS_MAIN_KEY，DS_HOT_KEY，DS_ARCHIVE_KEY
     * 备注：主库仅包含当前业务运营的必须数据（保留1到3年不等）
     *      热库仅包含业务查询统计的必须数据（保留半年到2年不等，并且非完整库表）
     *      归档库包含所有归档数据（保留5年以上）
     */
    public static final String DS_MAIN_KEY = "main";
    public static final String DS_HOT_KEY = "hot";
    public static final String DS_ARCHIVE_KEY = "archive";
    public static final String DS_MAIN_HOT_ARCHIVE_KEY = "main2hot2archive";
    public static final String DS_TYPE_HEADER = "x-ds-type";

}
